
package org.apache.mina.common;

/**
 * Represents the result of an ashynchronous I/O operation.
 * 
 * 封装异步IO操作的结果。
 */
public interface IoFuture {
    /**
     * Returns the {@link IoSession} which is associated with this future.
     * 
     * 返回与此future相关联的IoSession。
     */
    IoSession getSession();

    /**
     * Returns the lock object this future acquires.
     * 
     * 返回该future捕获的锁对象。
     */
    Object getLock();

    /**
     * Wait for the asynchronous operation to end.
     * 
     * 等待异步操作的结束。
     * 
     */
    void join();

    /**
     * Wait for the asynchronous operation to end with the specified timeout.
     * 
     * 等待异步操作在指定的时间内结束。
     * 
     * @return <tt>true</tt> if the operation is finished.
     */
    boolean join(long timeoutInMillis);

    /**
     * Returns if the asynchronous operation is finished.
     * 
     * 返回异步操作是否结束。
     */
    boolean isReady();

    /**
     * Adds an event <tt>listener</tt> which is notified when the state of this
     * future changes.
     * 
     * 添加一个事件监听器，当future状态改变时，该监听器将被通知。
     */
    void addListener(IoFutureListener listener);

    /**
     * Removes an existing event <tt>listener</tt> which is notified when the
     * state of this future changes.
     * 
     * 移动一个监听器。
     */
    void removeListener(IoFutureListener listener);
}
